package com.ruoyi.business.controller;

import com.ruoyi.business.domain.Census;
import com.ruoyi.business.service.ICensusService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * 经营统计Controller
 * 
 * @author zqd
 * @date 2024-09-12
 */
@RestController
public class CensusController extends BaseController
{
    @Autowired
    private ICensusService censusService;

    /**
     * 查询经营统计列表
     */
    @RequiresPermissions("business:census:list")
    @GetMapping("/census/{id}/{date}")
    public Census findList(@PathVariable String id,@PathVariable String date) {
        // 验证路径变量的有效性
        if (id == null || date == null) {
            throw new IllegalArgumentException("Path variables cannot be null");
        }
        Census census = censusService.selectCensus(id,date);
        return census;
    }


    @GetMapping("/census/type/{typeid}/{typedate}")
    public List<Map<String, String>> findType(@PathVariable String typeid, @PathVariable String typedate) {
        // 验证路径变量的有效性
        if (typeid == null || typedate == null) {
            throw new IllegalArgumentException("Path variables cannot be null");
        }
        List<Map<String, String>> maps = censusService.serviceType(typeid, typedate);
        return maps;
    }





    @GetMapping("/month/{id}/{date}")
    public Census findmonthList(@PathVariable String id,@PathVariable String date) {
        // 验证路径变量的有效性
        if (id == null || date == null) {
            throw new IllegalArgumentException("Path variables cannot be null");
        }
        Census census = censusService.selectMonths(id,date);
        return census;
    }


    @GetMapping("/month/type/{typeid}/{typedate}")
    public List<Map<String, String>> findmonthType(@PathVariable String typeid, @PathVariable String typedate) {
        // 验证路径变量的有效性
        if (typeid == null || typedate == null) {
            throw new IllegalArgumentException("Path variables cannot be null");
        }
        List<Map<String, String>> maps = censusService.serviceMonth(typeid, typedate);
        return maps;
    }






    @GetMapping("/year/{id}/{date}")
    public Census findyearList(@PathVariable String id,@PathVariable String date) {
        // 验证路径变量的有效性
        if (id == null || date == null) {
            throw new IllegalArgumentException("Path variables cannot be null");
        }
        Census census = censusService.selectYear(id,date);
        return census;
    }


    @GetMapping("/year/type/{typeid}/{typedate}")
    public List<Map<String, String>> findyearType(@PathVariable String typeid, @PathVariable String typedate) {
        // 验证路径变量的有效性
        if (typeid == null || typedate == null) {
            throw new IllegalArgumentException("Path variables cannot be null");
        }
        List<Map<String, String>> maps = censusService.serviceYear(typeid, typedate);
        return maps;
    }
}
